package com.sau.pixelcart.mapper;

import com.sau.pixelcart.domain.entity.User;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.time.LocalDateTime;

/**
 * <p>
 * 用户账户信息表 Mapper 接口
 * </p>
 *
 * @author Inton
 * @since 2025-03-08
 */

@Mapper
public interface UserMapper extends BaseMapper<User> {

    /**
     * 插入登录时间
     * @param userId
     * @param nowTime
     */
    @Update("update user set last_login_time = #{nowTime} where user_id = #{userId} ")
    void setLoginTime(@Param("userId") String userId, @Param("nowTime") LocalDateTime nowTime);

    /**
     * 更新密码
     *
     * @param userId
     * @param newPasswordMd5
     */
    @Update("update user set password = #{newPasswordMd5} where user_id = #{userId}")
    void changePassword(@Param("userId") String userId, @Param("newPasswordMd5") String newPasswordMd5);

    @Update("update user set password = '123456' where user_id = #{userId}")
    void resetPassword(@Param("userId") String userId);
}
